using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.TeamFoundation.Client;

namespace TfsSpam.Utilities
{
    /// <summary>
    /// The ServiceBase class serves as an abstract base class for the
    /// service-specific TFS utility classes.
    /// </summary>
    public abstract class ServiceBase
    {
        #region -- Constructor
        /// <summary>
        /// Standard constructor for the class, connects to the
        /// specified TFS server.
        /// </summary>
        /// <param name="serverUrl">The URL of the TFS server to connect to.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="serverUrl"/> is <c>null</c>.</exception>
        protected ServiceBase( Uri serverUrl )
        {
            if ( serverUrl == null )
            {
                throw new ArgumentNullException( "serverUrl" );
            }
            else
            {
                _server = TeamFoundationServerFactory.GetServer( serverUrl.ToString() );
            }
        }
        #endregion

        #region -- Protected properties
        /// <summary>
        /// The actual TFS server we're connected to.
        /// </summary>
        protected TeamFoundationServer Server
        {
            get { return _server; }
        } private TeamFoundationServer _server;
        #endregion
    }
}
